<!DOCTYPE html>
<html>
<head>
  <title>简易计算器</title>
  <style>
    body {
      font-family: Arial, sans-serif;
    }

    #calculator {
      width: 200px;
      height: 78px;
      margin: 0 auto;
      padding: 78px;
      border: 1px solid #ccc;
      border-radius: 5px;
      background-color: #f9f9f9;
    }

    #result {
      margin-bottom: 10px;
      padding: 10px;
      border: 1px solid #ccc;
      border-radius: 5px;
      background-color: #fff;
      text-align: right;
    }

    .button {
      width: 78px;
      height: 78px;
      font-size: 30px;
    }
    .button1 {
      width: 78px;
      height: 78px;
      font-size: 20px;
      background-image:url(1.png) ;
    }
    .button2{
      width: 78px;
      height: 78px;
      font-size: 20px;
      background-image:url(2.png) ;
    }
    .button3 {
      width: 78px;
      height: 78px;
      font-size: 20px;
      background-image:url(3.png) ;
    }
    .button4 {
      width: 78px;
      height: 78px;
      font-size: 20px;
      background-image:url(4.png) ;
    }
    .button5 {
      width: 78px;
      height: 78px;
      font-size: 20px;
      background-image:url(5.png) ;
    }
    .button6 {
      width: 78px;
      height: 78px;
      font-size: 20px;
      background-image:url(6.png) ;
    }
    .button7 {
      width: 78px;
      height: 78px;
      font-size: 20px;
      background-image:url(7.png) ;
    }
    .button8 {
      width: 78px;
      height: 78px;
      font-size: 20px;
      background-image:url(8.png) ;
    }
    .button9 {
      width: 78px;
      height: 78px;
      font-size: 20px;
      background-image:url(9.png) ;
    }
    .button:hover {
      background-color: #ccc;
    }

    .operator {
      background-color: #ff9800;
      color: #fff;
    }
  </style>
</head>
<body>
  <div id="calculator">
    <div id="result"></div>
    <table>
      <tr>
        <td><button class="button1" onclick="addInput('7')">7</button></td>
        <td><button class="button2" onclick="addInput('8')">8</button></td>
        <td><button class="button3" onclick="addInput('9')">9</button></td>
        <td><button class="button operator" onclick="addInput('/')">/</button></td>
      </tr>
      <tr>
        <td><button class="button4" onclick="addInput('4')">4</button></td>
        <td><button class="button5" onclick="addInput('5')">5</button></td>
        <td><button class="button6" onclick="addInput('6')">6</button></td>
        <td><button class="button operator" onclick="addInput('*')">*</button></td>
      </tr>
      <tr>
        <td><button class="button7" onclick="addInput('1')">1</button></td>
        <td><button class="button8" onclick="addInput('2')">2</button></td>
        <td><button class="button9" onclick="addInput('3')">3</button></td>
        <td><button class="button operator" onclick="addInput('-')">-</button></td>
      </tr>
      <tr>
        <td><button class="button" onclick="addInput('0')">0</button></td>
        <td><button class="button" onclick="addInput('.')">.</button></td>
        <td><button class="button operator" onclick="calculate()">=</button></td>
        <td><button class="button operator" onclick="addInput('+')">+</button></td>
      </tr>
      <tr>
        <td colspan="4"><button class="button" onclick="clearInput()">Clear</button></td>
      </tr>
      <tr>
        <td colspan="4"><button class="button" onclick="deleteLastCharacter()">DEL</button></td>
      </tr>
    </table>
  </div>

  <script>
    function addInput(value) {
      document.getElementById("result").innerHTML += value;
    }

    function clearInput() {
      document.getElementById("result").innerHTML = "";
    }

    function deleteLastCharacter() {
      var result = document.getElementById("result").innerHTML;
      document.getElementById("result").innerHTML = result.slice(0, -1);
    }

    function calculate() {
      var result = document.getElementById("result").innerHTML;
      var answer = eval(result);
      document.getElementById("result").innerHTML = answer;
    }
  </script>
</body>
</html>
